import Vue from 'vue'
import Vuex from 'vuex'

Vue.use(Vuex)

import VuexPersist from "vuex-persist";

const vuexLocal = new VuexPersist({
  storage: window.sessionStorage,
})

export default new Vuex.Store({
  state: {
    cartlist: [],
  },
  mutations: {
    addCart(state, goods) {
      state.cartlist.unshift(goods)
    },
    del(state, index) {
      state.cartlist.splice(index, 1)
    }
  },
  actions: {

  },
  getters: {

  },
  plugins: [vuexLocal.plugin],
})
